package cn.gwm.flink.streaming.strategy.estimatesoh;

import cn.gwm.flink.streaming.beans.estimateSoh.EstimateSohRecord;
import cn.gwm.flink.streaming.beans.estimateSoh.EstimateSohRecordPhev;
import cn.hutool.core.util.BooleanUtil;

import java.math.BigDecimal;
import java.util.Objects;

/**
 * 电池类型为NCM的ocv有效性判断策略
 *
 * @author GW00283474
 */
public class OcvNcmStrategyPhev implements OcvStrategyPhev {
    @Override
    public void execute(EstimateSohRecordPhev record) throws Exception{
        //最大soc是否OCV非平台有效性
        BigDecimal bmsInnerSocMax = record.getBMS_CellSOCMax();
        if (Objects.nonNull(bmsInnerSocMax)) {
            boolean frontFlag = bmsInnerSocMax.compareTo(new BigDecimal("0")) > -1 ? true : false;
            boolean endFlag = bmsInnerSocMax.compareTo(new BigDecimal("100")) < 1 ? true : false;
            if (BooleanUtil.and(frontFlag, endFlag)) {
                record.setPlatformValidFlagMax(true);
            }
        }
        //最小soc是否OCV非平台有效性
        BigDecimal bmsInnerSocMin = record.getBMS_CellSOCMin();
        if (Objects.nonNull(bmsInnerSocMin)) {
            boolean frontFlag = bmsInnerSocMin.compareTo(new BigDecimal("0")) > -1 ? true : false;
            boolean endFlag = bmsInnerSocMin.compareTo(new BigDecimal("100")) < 1 ? true : false;
            if (BooleanUtil.and(frontFlag, endFlag)) {
                record.setPlatformValidFlagMin(true);
            }
        }

    }


}
